package com.example.xcService.pojo.rabbitmq;

import com.example.entity.AgentOrder;
import com.example.service.IAgentOrderService;
import com.example.xcService.pojo.tool.OrderTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = {"notice.fanout.queue"} ,containerFactory = "listenerContainerFactory" ,concurrency = "50-100")
@Slf4j
public class NoticeFanoutConsumer {
    @Autowired
    OrderTool orderTool;
    @Autowired
    IAgentOrderService agentOrderService;

    @RabbitHandler
    @Async
    public  void SubmitOrder(String orderId){
       try{
           AgentOrder dbOrder=agentOrderService.getById(orderId);
           if (dbOrder!=null){
               orderTool.Notice(dbOrder);
           }
       }catch (Exception ex){
           log.error("回调消息队列出错",ex);
       }
    }
}
